<template>
  <div class="box">
    <div v-if="flag==1">
      <div class="display_flex">
        <div>
          施工片块：
          <el-select v-model="value" placeholder="全部">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </div>
        <div>
          开始时间：
          <el-date-picker v-model="value1" type="date" placeholder="选择日期"></el-date-picker>
        </div>
        <div>
          截止时间：
          <el-date-picker v-model="value1" type="date" placeholder="选择日期"></el-date-picker>
        </div>
        <div>
          <el-button type="primary">查询</el-button>
        </div>
      </div>
      <div class="zonghe_table">
        <el-table :data="tableData" style="width: 100%">
          <el-table-column type="index" show-overflow-tooltip label="序号"></el-table-column>
          <el-table-column prop="landName" label="自验地块"></el-table-column>
          <el-table-column prop="place" label="位置"></el-table-column>
          <el-table-column prop="time" label="自验时间"></el-table-column>
          <el-table-column label="操作" fixed="right">
            <!--   -->
            <template slot-scope="scope">
              <el-button size="mini" type="primary" @click="chakanItem(scope.row)">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="pages">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage4"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </div>

    <div class="landInfo" v-if="flag==2">
      <div class="back">
        <el-button icon="el-icon-back" size="small" @click="flag=1">返回</el-button>
      </div>
      <div class="title">
        <p class="title_one">{{itemData.landName}}</p>
        <p class="title_little">
          <span>施工自验时间：{{itemData.time}}</span>
          <span>自验人员：{{itemData.name}}</span>
        </p>
      </div>
      <div class="project_position">
        <div class="project_title">施工自验结果和结论</div>
        <div class="project_result">
          <div class="display_flex">
            <p>施工自验是否通过：</p>
            <el-radio-group v-model="radio">
              <el-radio label="YES">是</el-radio>
              <el-radio label="NO">否</el-radio>
            </el-radio-group>
          </div>
          <div class="display_flex">
            <p>施工自验结论</p>
            <el-input
              :readonly="true"
              type="textarea"
              :rows="5"
              placeholder="请输入内容"
              resize="none"
              v-model="ziyanText"
            ></el-input>
          </div>
          <!--  -->
        </div>
      </div>
      <div class="project_position">
        <div class="project_title">施工自验现场位置及轨迹</div>
        <div class="project_img">
          <img src="../../../assets/mapText.png" width="500" height="400" />
        </div>
      </div>
      <div class="project_position">
        <div class="project_title">施工自验资料</div>
        <div class="project_img">
          <el-table :data="imgArr" border style="width: 100%">
            <el-table-column type="index" show-overflow-tooltip label="序号" width="60"></el-table-column>
            <el-table-column prop="name" label="类型" width="200"></el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="primary"
                  fixed="left"
                  @click="btnSeeImg(scope.row)"
                >查看</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>

    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="seeImgDialog" width="50%">
      <div class="seeImg">
        <img :src="$https+titleSrc" width="80%" height="500" />
        <!-- <img :src="imgPath" width="80%" height="500"> -->
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  constructingSelfSupervisingInfo,
  constructingSelfSupervisingCheck
} from "@/api/implementationSelfTest";
export default {
  data() {
    return {
      flag: 1,
      options: [
        {
          value: "0",
          label: "全部"
        },
        {
          value: "1",
          label: "莲花村片区片块7-1"
        },
        {
          value: "2",
          label: "莲花村片区片块7-2"
        },
        {
          value: "3",
          label: "莲花村片区片块7-3"
        }
      ],
      value: "",
      value1: "",
      radio: "",
      tableData: [],
      needInfo: {
        page: 1,
        size: 10
      },
      total: 0,
      currentPage4: 4,
      seeImgDialog: false,
      imgArr: [],
      title: "",
      titleSrc:'',
      textarea: "",
      itemData: "", //单条数据
      ziyanText: "" //自验结论
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    //查看想
    chakanItem(row) {
      this.itemData=row
      console.log(this.itemData,"单条数据-施工自检")
      this.radio=row.yesOrNo
      this.ziyanText=row.opinion

      var data = {
        landId: row.landId,
        page:1,
        size:99999,
      };
      constructingSelfSupervisingCheck(data).then(res => {
        console.log(res);
        if(res.code==1000){
          this.flag = 2;
          var arr=[]
          res.data.rows.forEach((v,i)=>{
            var obj={name:'施工自验照片'+(i+1),src:v}
            arr.push(obj)
          })
            this.imgArr=arr
        }
      });
    },
    getData() {
      var data = {};
      var objArr = this.needInfo;
      for (var index in objArr) {
        if (objArr[index] != "" && objArr[index] != null) {
          data[index] = objArr[index];
        }
      }
      data["projectId"] = localStorage.getItem("projectId");
      constructingSelfSupervisingInfo(data).then(res => {
        console.log(res,"真实数据");
        this.tableData = res.data.rows;
        this.total = res.data.total;
      });
    },
    btnSeeImg(row) {
      this.title = row.name;
      this.titleSrc = row.src;
      this.seeImgDialog = true;
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    }
  }
};
</script>

<style lang="scss" scoped>
* {
  box-sizing: border-box;
}
.box {
  padding: 30px;
}
.display_flex {
  display: flex;
  align-items: center;
}
.display_flex div {
  margin-right: 20px;
  font-size: 14px;
  color: #333;
}
.project_result .display_flex {
  margin: 20px 30px 20px 40px;
}
.project_result .display_flex p {
  font-size: 13px;
  color: #444;
  width: 180px;
}
.project_result .display_flex:first-child p {
  width: 160px;
}
.zonghe_table {
  margin: 20px 0px;
}
.pages {
  text-align: center;
}
.seeImg {
  text-align: center;
}
.landInfo {
  border: 1px solid #efefef;
  box-sizing: border-box;
}
.back {
  margin: 20px;
}
.title_one {
  text-align: center;
  line-height: 40px;
  font-size: 20px;
  color: #444;
  font-weight: bold;
}
.title_little {
  font-size: 13px;
  color: #999;
  margin: 40px 20px 20px 30px;
}
.title .title_little span {
  margin-right: 30px;
}
.project_title {
  background: #f8f8f8;
  height: 50px;
  background: #f8f8f8;
  padding: 0px 30px;
  line-height: 50px;
  color: #48494d;
  font-size: 14px;
  font-weight: bold;
  border-top: 1px solid #efefef;
  border-bottom: 1px solid #efefef;
}
.project_img {
  padding: 30px;
}
</style>